/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package group2assignone.ucm.manager;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import group2assignone.view.manager.*;
import group2assignone.model.GSTax;
import group2assignone.ucm.UCController;

/**
 * Use Case: Edit GST Save                                                  <br>
 * Pre-condition: User clicks save from Edit GST view                      .<br>
 * Post-condition: Manager Main view is displayed                           <br>
 * 1. system exits the current view                                         <br>
 * 2. System retrieves the new gst data                                     <br>
 * 3. System sets the new GST data                                          <br>
 * 4. System restores Manager Main VIew                                      <br>
 *  1. a) Invalid GST entry                                                 <br>
 *          - display error                                                 <br>
 * @author group2
 */
public class UCEditGSTSave implements UCController {

    private GSTax tax;
    private EditGSTView view;

    public UCEditGSTSave(EditGSTView view, GSTax tax) {
        this.tax = tax;
        this.view = view;

    }

    public void run() {
        // tax.setGST(view.getInput());
        if (view.getInput().length() > 0) {
            //1. system exits the current view
            view.dispose();
            //2. System retrieves the new gst data
            int val = Integer.parseInt(view.getInput());
            //3. System sets the new GST data
            tax.setGST(val);
            //4. System restores Manager Main VIew
            ManagerView mv = ManagerView.getInstance();
            mv.go();
        } else {
            //1. a) Invalid GST entry                                                 <br>
            //        - display error                                                 <br>
            System.err.println(" invalid gst");
        }
    }
}
